<?php

namespace app\admin\model;

use think\Model;


class Withdraw extends Model
{

    

    

    // 表名
    protected $name = 'withdraw';
    
    // 自动写入时间戳字段
    protected $autoWriteTimestamp = 'integer';

    // 定义时间戳字段名
    protected $createTime = 'createtime';
    protected $updateTime = false;
    protected $deleteTime = false;

    // 追加属性
    protected $append = [
        'status_text',
        'position_text'
    ];
    

    
    public function getStatusList()
    {
        return ['created' => __('Status created'), 'successed' => __('Status successed'), 'rejected' => __('Status rejected')];
    }

  public function getTypeList()
  {
    return ['微信' => __('微信'), '支付宝' => __('支付宝')];
  }

    public function getPositionList()
    {
        return ['1' => __('Position 1'), '2' => __('Position 2'), '3' => __('Position 3')];
    }


    public function getStatusTextAttr($value, $data)
    {
        $value = $value ? $value : (isset($data['status']) ? $data['status'] : '');
        $list = $this->getStatusList();
        return isset($list[$value]) ? $list[$value] : '';
    }

  public function getTypeTextAttr($value, $data)
  {
    $value = $value ? $value : (isset($data['type']) ? $data['type'] : '');
    $list = $this->getTypeList();
    return isset($list[$value]) ? $list[$value] : '';
  }


    public function getPositionTextAttr($value, $data)
    {
        $value = $value ? $value : (isset($data['position']) ? $data['position'] : '');
        $list = $this->getPositionList();
        return isset($list[$value]) ? $list[$value] : '';
    }




    public function user()
    {
        return $this->belongsTo('User', 'user_id', 'id', [], 'LEFT')->setEagerlyType(0);
    }
}
